package bsh.dyn;

import java.util.HashMap;
import java.util.Map;

/**
 * Trivial implementation of a {@link JITCompiler}. It actually does nothing at the moment
 * 
 * @author takeshi
 */
public class NoOpJITCompiler implements JITCompiler {

    /**
     * {@inheritDoc}
     */
    public Invocable compileInvocable(Invocable invocable) {
        return invocable;
    }

    /**
     * {@inheritDoc}
     */
    public ColapsedInvocable compileColapse(int[] callSiteIds, Invocable[] invocables) {
        Map<Integer, Invocable> map = new HashMap<Integer, Invocable>(callSiteIds.length);
        for (int i = 0; i < invocables.length; i++) {
            Invocable invocable = invocables[i];
            map.put(Integer.valueOf(callSiteIds[i]), invocable);
        }
        return new CollapsedInvocableImpl(map);
    }

}
